<?php

namespace Common\Taglib;

use Common\Lib\Relation;

class bbsreply
{
    public function run($opt)
    {
        $bid = intval($opt['bid']);
        $page = intval($opt['page']);
		$startrow  = intval($opt['startrow']);
		$uid  = intval($opt['uid']);
		$sort = trim($opt['sort']) ?: 'id desc';
        $num = empty($opt['num']) ? 15 : intval($opt['num']);

        if ($bid) {
            $map['bid'] = $bid;
        }
		if (!empty($uid)) {
            $map['uid'] = $uid;
        }
        $lists = D('BbsReply')->get_list($map, $page, $sort, $num,$startrow);

        $list = $lists['list'];
        $list = Relation::belongsTo($list, 'User', 'uid', 'uid', 'adduser', array(D('User'), 'auto_user_fill'));
		$list = Relation::belongsTo($list, 'Bbs', 'bid', 'id', 'bbs', array(D('Bbs'), 'fill'));

        $lists['list'] = $list;
        return $lists;
    }
}
?>